<template>
  <div class="main">子组件</div>
</template>
<script setup>
import { onMounted, onBeforeMount } from "vue";

const emit = defineEmits(["getLifeCycle"]);
emit("getLifeCycle", "子组件-created");

const fn = () => {
  console.log("子组件里的一个函数");
};

onMounted(() => {
  console.log("子组件 mounted");
  emit("getLifeCycle", "子组件-obMounted");
});

onBeforeMount(() => {
  console.log("子组件 onBeforeMount");
});

defineExpose({
  fn,
});
</script>
<style lang="scss" scoped>
.main {
  color: red;
  font-size: 20px;
}
</style>
